package com.gmu.uav;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.ImageView;

public class VideoActivity extends Activity{
	
	 private ImageView m_JPGView = null;
	
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.video_feed);
	        
	        m_JPGView = (ImageView)findViewById(R.id.jpgview);
	       
		    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	    }
	
	  public void displayImage(byte[] jpegData)
	    {
	    	BitmapFactory.Options options = new BitmapFactory.Options();
	    	options.inSampleSize = 2;
	    	
	    	Bitmap bm = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length, options);
	    	m_JPGView.setImageBitmap(bm); 
	    	bm.recycle();
	    }
	  
	  @Override
		public boolean onCreateOptionsMenu(Menu menu) {
		    MenuInflater inflater = getMenuInflater();
		    inflater.inflate(R.menu.global_menu, menu);
		    return true;
		}
		
		@Override
		public boolean onOptionsItemSelected(MenuItem item) {
		    // Handle item selection
		    switch (item.getItemId()) {
		        case R.id.switchToMap:
		        	 startActivity(new Intent(getApplicationContext(), MapViewActivity.class));
		            return true;
		        case R.id.switchToFeed:
		           
		            return true;
		        case R.id.switchToController:
		            startActivity(new Intent(getApplicationContext(), ControllerActivity.class));
		            return true;
		        default:
		            return super.onOptionsItemSelected(item);
		    }
		}
}
